package priv.conceit.study.book.lambda.chapter3;

import lombok.AllArgsConstructor;
import lombok.Data;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;

/**
 * map
 *
 * 转换类型为新的流
 *
 * @author Conceit
 * @since 1.0.0, 2021/9/10
 */
@Data
@AllArgsConstructor
public class Map {


    private Long age;
    private String name;



    public static void main(String[] args) {
        List<Map> maps=new ArrayList<>();
        maps.add(new Map(1L,"a"));
        maps.add(new Map(2L,"b"));
        maps.add(new Map(3L,"c"));
        maps.add(new Map(4L,"d"));
        maps.add(new Map(5L,"e"));
        //方法引用
        map1(maps);
        //map内部处理
        //map2(maps);

    }

    public static String convertString(Map map){
        return String.valueOf(map.age);
    }

    public static void map1(List<Map> maps){
        maps.stream().map(Map::convertString).forEach(System.out::println);
        maps.stream().map(map -> String.valueOf(map)).forEach(System.out::println);
    }

    public static void map2(List<Map> maps){
        maps.stream().map(map->{
            return String.valueOf(map.age);
        }).forEach(System.out::println);
    }

}
